﻿package model.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import model.entity.product.Product;

@Entity
@Table(name="BillItem")
@IdClass(value=BillItemId.class)
public class BillItem {

	private int quantity;
	private double eventDiscountPercent;
	private int saleTimePrice;
	
	@Id
	@ManyToOne
	private ConcreteBill bill;
	
	@Id
	@ManyToOne
	private Product product;

	@Override
	public String toString() {
		return "BillItem [quantity=" + quantity + ", eventDiscountPercent="
				+ eventDiscountPercent + ", saleTimePrice=" + saleTimePrice
				+ ", product=" + product.getName() + "]";
	}

	public BillItem() {
		super();
	}
	
	public BillItem(int quantity, double eventDiscountPercent,
			int saleTimePrice, ConcreteBill bill, Product product) {
		this.quantity = quantity;
		this.eventDiscountPercent = eventDiscountPercent;
		this.saleTimePrice = saleTimePrice;
		this.bill = bill;
		this.product = product;
	}
	
}
